using System;
using System.Collections.Generic;
using System.Text;

namespace PaulRz.Util.Patterns
{
    public abstract class WorkerPipelineElement<TInput, TOutput> : PipelineElement<TInput, TOutput>
        where TInput : class
        where TOutput : class 
    {
        protected WorkerPipelineElement(string name, ILogInterface logger, int joinTime) : base(name, logger, joinTime)
        {
        }

        protected abstract TOutput ProcessMessage(TInput message);
        
        protected override void ProcessCycle()
        {
            TInput message = Input.Dequeue();
            TOutput processedMessage = ProcessMessage(message);
            if (processedMessage!=null)
                Output.Enqueue(processedMessage);
        }
        
    }
}
